package com.glory.hikvisionmobile.adapter;

import android.view.View;
import android.widget.CheckBox;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.hikvisionmobile.R;
import com.glory.hikvisionmobile.bean.from.DrugAddBean;
import com.glory.hikvisionmobile.bean.from.DrugInfoBean;

import java.util.ArrayList;
import java.util.List;

/**
 * FileName: DrugInfoAdapter
 * Author: XJH
 * Date: 2020/3/13 15:56
 * Description: 药液信息
 * History:
 */
public class DrugInfoAdapter extends BaseQuickAdapter<DrugInfoBean,BaseViewHolder> {

    private List<String> removeList ;

    private boolean enable = true;

    public DrugInfoAdapter(@Nullable List<DrugInfoBean> data) {
        super(R.layout.adapter_param_list,data);
        removeList = new ArrayList<>();
    }

    public void setEnable(boolean enable){
        this.enable = enable;
    }

    @Override
    protected void convert(BaseViewHolder helper, DrugInfoBean item) {
        helper.setText(R.id.tvItem1,item.getYaoYe());
        helper.setText(R.id.tvItem2,item.getYaoYeDesc());
        helper.setText(R.id.tvItem3,item.getYaoYeLot());
        helper.setGone(R.id.tvItem4,false);
        helper.setGone(R.id.tvItem5,false);
        helper.setGone(R.id.cbLayout,true);
        CheckBox cb = helper.getView(R.id.pauseCb);
        cb.setChecked(false);
        cb.setEnabled(enable);
        cb.setTag(helper.getAdapterPosition());
        cb.setOnClickListener(view -> {
            if (cb.isChecked()){
                removeList.add(String.valueOf(helper.getAdapterPosition()));
            }else {
                if (removeList.contains(String.valueOf(helper.getAdapterPosition()))){
                    removeList.remove(String.valueOf(helper.getAdapterPosition()));
                }
            }
        });
    }

    public List<String> getRemoveList(){
        return removeList;
    }


}
